<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<title>参数字典维护</title>
		
		<link rel="stylesheet" type="text/css" href="./css/cm-default.css"  />
		<link rel="stylesheet" type="text/css" href="./ligerUI/skins/Aqua/css/ligerui-all.css" />
		<script src="./js/jquery-min.js" type="text/javascript"></script>
		<script src="./ligerUI/js/ligerui.min.js" type="text/javascript"></script>
		<script src="./js/common.js" type="text/javascript"></script>
		<script type="text/javascript">
			var grid;
			$(function(){
				$("#layout_main").ligerLayout({
					rightWidth:310,
                    allowRightResize:false
                });

               	grid = $("#query_list").ligerGrid({
                    columns:[
	                    //{display:'编号',name:'id',width:50,align:'right'} ,
	                    {display:'名称',name:'name',width:180,minWidth:60,align:'left'},
	                    {display:'代码',name:'code',width:180,align:'left',frozen:false},
	                    {display:'状态',name:'status',width:50,data:status,render:function(item){return item.status=='1'?'有效':'无效';}},
	                    {display:'说明',name:'description',align:'left'}
                    ],
                    pageSize:20,
                    usePager: true,
                    sortName:'id',
                    width:'100%',
                    height:'100%',
                    checkbox:true,
                    rownumbers:false,
                    fixedCellHeight:false,
                    colDraggable:true,
                    onSelectRow:getSelected,
                    onUnSelectRow:unselected,
                    onReload: toQuery,
                    onToFirst: toFirst,
                    onToLast: toLast,
                    onToNext: toNext,
                    onToPrev: toPrev
				});
				$("#pageloading").hide();
			});

			function toQuery(item, page, pageSize) {
				if (!page)
					page = grid.options.page; //$(".pcontrol input[type='text']").val();
				if (!pageSize)
					pageSize = grid.options.pageSize; //$("select[name='rp']").val();
				var url = "/cmwifi/rbac/cmDict.do?m=q&p=" + page + "&cp=" + pageSize;
				
				var dName = $("#dictName").val();
				var dCode = $("#dictCode").val();
				var data = '{';
				if (dName !== "")
					data += '"name":"' + dName + '"';
				if (dCode !== "")
					data += ',"code":"' + dCode + '"';
				data = data.replace(/\{,/, "{") + "}";
				
				ajaxSubmit(url, data, function(data) {
					$("#query_list").ligerGrid({
		                data: data
					});
				})
			}
			function toFirst() {
				toQuery(null, 1);
			}
			function toLast() {
				var p = parseInt(grid.options.total / grid.options.pageSize);
				if (grid.options.total % grid.options.pageSize > 0)
					p += 1;
				toQuery(null, p);
			}
			function toNext() {
				var p = parseInt(grid.options.total / grid.options.pageSize);
				if (grid.options.total % grid.options.pageSize > 0)
					p += 1;
				if (grid.options.page == p)
					return;
				toQuery(null, grid.options.page + 1);
			}
			function toPrev() {
				if (grid.options.page == 1)
					return;
				toQuery(null, grid.options.page - 1);
			}

			function getSelected(row) {
				if (!row) return;
				$(".dict-info #dictId").val(row.id);
				$(".dict-info #name").val(row.name);
				$(".dict-info #code").val(row.code);
				$(".dict-info #status").val(row.status);
				$(".dict-info #desc").val(row.description);
			}
			function unselected() {
				toReset(".dict-info input,select,textarea");
			}
	    </script>
		<style type="text/css">
			label{margin: 5px 20px 5px 15px;}
			.fields{height:35px;padding-top:5px;}
			.dict-info{width: 260px;padding: 10px;}
			.diff {margin:3px 0;}
		</style>
	</head>
	<body style="padding:0;">
		<div id="pageloading"></div>  
		<div id="layout_main">
			<div position="center" id="a_center" title="参数字典列表">
				<div id="query_cond" class="fields">
					<label>参数名称</label><input type="text" class="txt-def" id="dictName" />
					<label>参数代码</label><input type="text" class="txt-def" id="dictCode" />
					<input type="button" value="查询" style="margin-left:25px;" onclick="toQuery();" />
					<input type="button" value="清空" onclick="toReset('#dictName,#dictCode');" />
				</div>
				<div id="query_list"></div>
			</div>
			<div position="right" id="a_right" title="参数定义">
				<div class="dict-info" style="text-align:center;">
					<input type="button" value="保存" />
					<input type="button" value="新增" />
					<input type="button" value="清空" onclick="unselected();" />
				</div>
				<div class="dict-info">
					<input type="hidden" id="dictId" />
					<label>名称</label><input type="text" class="txt-def diff" id="name" />
					<label>代码</label><input type="text" class="txt-def diff" id="code" />
					<label>状态</label><select id="status" class="txt-def diff" param="rbac.status" style="margin-right:150px;">
						<option value=""></option>
						<option value="1">有效</option>
						<option value="0">无效</option>
					</select>
					<label style="vertical-align:top;">描述</label><textarea class="diff" id="desc" cols="25" rows="3" value=""></textarea>
				</div>
				<div class="dict-info" style="text-align:center;">
					<a href="javascript:void(0);">管理参数字典项>></a>
				</div>
			</div>
		</div>
	</body>
</html>